package com.hy.demo.learn.thread;

/**
 * <p>
 *
 * </p>
 *
 * @author cjl
 * @version 1.0
 * @since 2020-07-29 14:21
 */
public class Test {
    public static void main(String[] args) throws InterruptedException {

        Thread mainThread = Thread.currentThread();
        Thread thread = new Thread(() -> {
            try {
                System.out.println(" **** 开始睡眠 ***** ");
                Thread.sleep(10000);
                System.out.println(" **** 正常睡眠完成 **** ");
            } catch (InterruptedException e) {
                System.out.println(" **** 线程中断 **** ");
            }

        });
        thread.start();
        Thread.sleep(1000);
        if (!thread.isInterrupted()) {
            System.out.println(" **** 我去中断你 **** ");
            thread.interrupt();
        }
    }
}
